package com.service.impl;

import com.bean.entity.Classes;
import com.bean.entity.District;
import com.bean.pojo.PageAssistant;
import com.bean.vo.ClassesVo;
import com.dao.ClassesMapper;
import com.dao.DistrictMapper;
import com.service.ClassesService;
import com.service.DistrictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 街道基础业务逻辑实现
 */
@Service
public class DistrictServiceImpl implements DistrictService {

    @Autowired
    private DistrictMapper districtMapper;

    public int save(District t) throws Exception {
        return districtMapper.insert(t);
    }

    public int remove(District t) throws Exception {
        return districtMapper.delete(t);
    }

    public int modify(District t) throws Exception {
        return districtMapper.update(t);
    }

    public District unique(District t) throws Exception {
        List<District> districtList = districtMapper.select(t);
        if (districtList.size()!=1) throw new Exception("您要查询的学生分数暂未找到！");
        return districtList.get(0);
    }

    public List<District> query(District t) {
        return districtMapper.select(t);
    }

    public PageAssistant<District> queryByPage(Map<String, Object> map, PageAssistant<District> pa) {
        //查询并设置总记录数
        pa.setCount(districtMapper.selectCount(map));
        //添加分页参数
        map.put("startCode", pa.getStartCode());
        map.put("pageSize", pa.getPageSize());
        //查询并设置页面内容
        pa.setItems(districtMapper.selectByPage(map));
        return pa;
    }
}
